package com.gs.coursera.algorithms.core.graph;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Sabuj
 *
 * @param <T>
 * @param <W>
 */
public abstract class Path<T, W extends Comparable<W>> {

	private Graph<T, W> graph;
	private Vertex<T, W> sourceVertex;
	private List<Vertex<T, W>> edgeWalk = new ArrayList<Vertex<T,W>>();
	
	public Path(Graph<T, W> graph, T source) {
		this.graph = graph;
		for(Vertex<T, W> v : graph.getVertices()){
			if(source.equals(v.getValue())){
				this.sourceVertex = v;
				break;
			}
		}
		
		//getEdgeWalk().add(sourceVertex);
		//doSearch(graph, sourceVertex);
	}
	
	
	public Graph<T, W> getGraph() {
		return graph;
	}


	public void setGraph(Graph<T, W> graph) {
		this.graph = graph;
	}


	public Vertex<T, W> getSourceVertex() {
		return sourceVertex;
	}


	public void setSourceVertex(Vertex<T, W> sourceVertex) {
		this.sourceVertex = sourceVertex;
	}


	public List<Vertex<T, W>> getEdgeWalk() {
		return edgeWalk;
	}


	public void setEdgeWalk(List<Vertex<T, W>> edgeWalk) {
		this.edgeWalk = edgeWalk;
	}


	public abstract boolean hasPathTo(Vertex<T, W> to);
	public abstract Iterable<Vertex<T, W>> pathTo(Vertex<T, W> to);
	public abstract void doSearch(Graph<T, W> graph, Vertex<T, W> source);
	
}
